<%--
  Created by IntelliJ IDEA.
  User: 86158
  Date: 2022/10/24
  Time: 9:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>HRM</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
</head>
<body>

<div class="layui-card layui-content">
    <div class="layui-card-body">
        <form class="layui-form" action="" lay-filter="component-form-element">
            <input type="hidden" id="id" name="id" value="${user.id}">
            <div class="layui-col-lg6">
                <label class="layui-form-label">账号</label>
                <div class="layui-input-block">
                    <input type="text"
                           name="loginName"
                           value="${user.loginName}"
                           required lay-verify="required"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <br>


            <div class="layui-col-lg6">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text"
                           name="userName"
                           value="${user.userName}"
                           required lay-verify="required"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <br>
            <br>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="Add-filter">修改</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

        form.on('submit(Add-filter)', function (data) {
            $.ajax({
                url: "${pageContext.request.contextPath}/user/update",
                type: "post",
                contentType: "application/json",
                data: JSON.stringify(data.field),
                dataType: 'json',
                success: function (data) {
                    if (data=="1"){

                        layer.msg("操作成功", {
                            icon: 1,
                            success: function () {
                                var frameIndex = parent.layer.getFrameIndex("Update-frame");
                                parent.layer.close(frameIndex);
                                var dom=$("#SearchBtn", window.parent.document);
                                dom.trigger("click");
                            }
                        });
                    }else {
                        layer.msg("修改失败",{icon:2});
                    }
                },
                error: function (e) {
                        layer.msg(e.responseText, {icon: 2});
                }

            })
            return false;
        });
    });

</script>

</body>
</html>
